﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;

namespace RestaurateurConsole
{
    public class DataEncapsulator
    {
        private Restaurateur db = new Restaurateur(Properties.Settings.Default.RestaurateurConnectionString);
        private static MemoryStream ms = new MemoryStream();
        private static StreamWriter writer;

        public DataEncapsulator()
        {
            db.Log = writer;
        }

        static DataEncapsulator()
        {
            writer = new StreamWriter(ms);
        }

        public static StreamWriter Writer { get { return writer; } }
        public static byte[] Stream 
        { 
            get 
            {
                writer.Flush();
                return ms.GetBuffer(); 
            } 
        }

        public Restaurateur DB
        {
            get
            {
                return db;
            }
        }

        static public TextWriter Log
        {
            get
            {
                return Console.Out;
            }
        }

        
    }
}
